//
//  RootViewController.m
//  UI04_触摸
//
//  Created by yutao on 15/10/14.
//  Copyright (c) 2015年 yutao. All rights reserved.
//

#import "RootViewController.h"

@interface RootViewController ()

@end

@implementation RootViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    self.view.backgroundColor = [UIColor yellowColor];

    //响应者类
//  UIResponder

    //响应者链
    //当用户触摸屏幕,产生一个事件,硬件拿到事件,将事件传递给应用,应用传递给window,window检测它上面的所有子视图,如果有子视图,将事件传递给子视图,直到当前子视图没有子视图时.才开始判断自己能不能响应事件.自己响应不了就将事件抛给父视图响应
    //事件检测从底层视图往子视图上检测
    //事件响应是从子视图往下响应.


//    UILabel 和 UIImageView 默认用户交互是关闭的
    //打开用户交互 默认是yes(UILabel,UIImageView默认是NO)
    self.view.userInteractionEnabled = YES;

    


}
//开始触摸
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{

    //打印当前方法名
    NSLog(@"%s",__FUNCTION__);
    self.view.backgroundColor = [UIColor colorWithRed:arc4random() % 256 / 255.0 green:arc4random() % 256 / 255.0 blue:arc4random() % 256 / 255.0 alpha:1.0];

}
//手指在屏幕上移动时触发
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
    NSLog(@"%s",__FUNCTION__);

}
//手指离开屏幕时触发
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
    NSLog(@"%s",__FUNCTION__);

}
//来电话时,被动断开触摸时触发
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
{
    NSLog(@"%s",__FUNCTION__);

}
//摇一摇开始
- (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
    NSLog(@"%s",__FUNCTION__);
}
//摇一摇结束
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
    NSLog(@"%s",__FUNCTION__);

}
//摇一摇中断
- (void)motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
    NSLog(@"%s",__FUNCTION__);

}




- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
